<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<%@ include file="/WEB-INF/views/include/head.jsp"%>
<link rel="stylesheet" href="${ctxStatic}/css/list.css">
<script type="text/javascript">

$(function(){
    $("#stop2").prop("checked",true);
    var countNeed = 0;
    $("input[name='signFlag']").each(function(i,e){
        //alert("here");
        //if($(e).prop("checked")){
            $("#stop1").prop("checked",true);
            countNeed = 1;
        //}
    });
    if (countNeed == 0) {
         $("#stop2").prop("checked",true);
         $("#show").hide();
    }
});
//下拉框信息信息查询
function selectAcc(id){
    
    strs=id.split("-"); 
    var cd=strs[0];
    var id=strs[1];
    id=cd+id;
    
    if($("#"+id).prop("disabled")){
           
           $("#"+id).removeAttr("disabled");
           var param={"code":strs[1]};
           $.post("${ctx}/style/mystyle/formtwotoptwo",param,function(result){
               var html="<option value=''><spring:message code="order_please_choose"/></option>";
               $.each(result,function(i,e){
                   html+="<option value='"+e.styleOption.itemCd+"-"+e.styleOption.itemValue+"'>"+e.styleOption.itemNameCn+"</option>";
               });
               changeTitleInfo();
               $("#"+id).html(html);
           },'json');
           
    }else{
           $("#"+id).attr("disabled","disabled");
           changeTitleInfo();
           var html="<option value=''><spring:message code="order_please_choose"/></option>";
           $("#"+id).html(html);
    }
}


/*下拉框信息信息查询*/
function selectAcc2(id){

    var oldId = id;
    var strs=id.split("-"); 
    var cd=strs[0];
    var id=strs[1];
    id=cd+id;
       
       $("#"+id).removeAttr("disabled");
       var param={"code":strs[1]};
       $.post("${ctx}/style/mystyle/formtwotoptwo",param,function(result){
           var html= "<select class='form-control sexLg'  name='signOptionList' disabled='disabled' id='" + id +"'>";
           html+="</select>";
           $("#"+id + "C").html(html);
           changeTitleInfo();
       },'json');
      
    var idCK = id + "CK";
    var html2 = '<input type="checkbox" name="signItemList" value="' + oldId + '"  onclick="selectAcc(\'' + oldId + '\' )">';
    $("#"+ idCK).html(html2);

}


/*id 隐藏范围 flag=1 展示 2隐藏*/
function showOrHide(id,flag){

    if(flag==1){
        
        $("#"+id).show();
        $("#"+id).find("input").attr("disabled",false);
        $("#"+id).find("select").attr("disabled",false);
    }else{
        
        $("#"+id).hide();
        $("#"+id).find("input").attr("disabled",true);
        $("#"+id).find("select").attr("disabled",true);
    }
    
}

/*下一步*/
var saveForm={
    s:null,
    save:function(s){
            this.s=s;
            if (!validate()){
                return;
            }
            $("#inputForm").validate({
                submitHandler : function() {
                    var params = $("#inputForm").serialize();
                    // 算价格
                    $.post("${ctx}/order/createOrder3/saveOrderToSession7", params, function(result) {
                        
                        // 有错误
                        if (result == "false") {
                            $("#inputForm")[0].reset();
                        }
                         // 跳转至第二页面
                        else {
                            window.location.href="${ctx}/order/createOrder3/form8?id=0";
                        }
                    }, 'json');
                }
            });
            
            $("#inputForm").validate({});
            $("#inputForm").submit(); 
    }
    }
    
/*入力是否合法*/
function validate() {

    // checkBox
    var cb = $("input[name='signItemList']");
    // option
    var op = $("select[name='signOptionList']");
    
    for (var i = 0 ; i < cb.length; i ++) {
        // 加值，减值只能入力其中一个数据
        if (cb[i].checked) {
            if(op[i].value == null || $.trim(op[i].value) == "" || op[i].value == "null") {
                // 请选择相应选项
                layer.msg('<spring:message code="order_please_choose_option_item"/>', {time:1000}); 
                return false;
            }
           
        }
    }
   return true;
}


/*标题*/
function changeTitleInfo() {

    var params = $("#inputForm").serialize();

    $.post("${ctx}/order/createOrder/titleShow2?typeFlag=7&&id=0", params, function(result) {
    
        var h = $(callBackHtml(result)).find("#title").html();
        $('#title').html(h);
        var windowH2 = window.parent.windowHIframe;
        $('.TxtInfoSm1,.scrollBox').css('height', windowH2 - 368);
    }, 'html');

}

</script>
</head> 
<body>
    <div class="myshop">
        <!-- 创建订单 -->
        <p class="myshoptop"><spring:message code="order_create_order"/></p>
    </div>
        <div class="myshop_middle_order">
        <!-- 标题 -->
        <div class="orderTit orderTitShow clearfix">
            <div class="titSm off">
                <!-- 基本信息 -->
                <p><spring:message code="order_basic_info"/></p>
                <img src="${ctxStatic}/images/order_01_off.png">
            </div>
            <div class="titSm off" onclick='window.location.href="${ctx}/order/createOrder2/initUpdateOrder2?id=${order.id}"'>
                <!-- 量体信息 -->
                <p><spring:message code="order_fit_property_info"/></p>
                <img src="${ctxStatic}/images/order_02_off.png">
            </div>
            <div class="titSm off" onclick='window.location.href="${ctx}/order/createOrder3/form3?id=${order.id}"'>
                <!-- 款式定制 -->
                <p><spring:message code="order_style_customization"/></p>
                <img src="${ctxStatic}/images/order_03_off.png">
            </div>
            <div class="titSm off" onclick='window.location.href="${ctx}/order/createOrder3/form4?id=${order.id}"'>
                <!-- 辅料 -->
                <p><spring:message code="order_accessory"/></p>
                <img src="${ctxStatic}/images/order_04_off.png">
            </div>
            <div class="titSm off" onclick='window.location.href="${ctx}/order/createOrder3/form5?id=${order.id}"'>
                <!-- 配料 -->
                <p><spring:message code="order_burdening"/></p>
                <img src="${ctxStatic}/images/order_05_off.png">
            </div>
            <div class="titSm off" onclick='window.location.href="${ctx}/order/createOrder3/form6?id=${order.id}"'>
                <!-- 刺绣 -->
                <p><spring:message code="order_embroidery"/></p>
                <img src="${ctxStatic}/images/order_06_off.png" >
            </div>
            <div class="titSm off" onclick='window.location.href="${ctx}/order/createOrder3/form7?id=${order.id}"'>
                <!-- 标牌 -->
                <p><spring:message code="order_brand"/></p>
                <img src="${ctxStatic}/images/order_07_off.png" onclick='window.location.href="${ctx}/order/createOrder3/form7?id=0"'>
            </div>
            <div class="titSm off" onclick='window.location.href="${ctx}/order/createOrder3/form8?id=${order.id}"'>
                <!-- 售价 -->
                <p><spring:message code="order_sales_price"/></p>
                <img src="${ctxStatic}/images/order_08_on.png">
            </div>
        </div>

        
            <div class="top_first clearfix">
                <div class="contentBox cnBx">
                    <!-- 标牌 -->
                    <p class="contentTit cnBy"><spring:message code="order_brand"/></p>
                    <form id="inputForm">
                            <div class="formBox scrollBox">
                                <div class="clearfix">
                                    <div class="ch_middle fl">
                                        <!-- 标牌 -->
                                        <p class="data_92"><spring:message code="order_brand"/></p>
                                        <div class="data_lf fl">
                                            <label class="lbst1"><input class="rast1" id="stop1" name="stop1" type="radio" onclick="showOrHide('show',1)"><spring:message code="order_require"/></label>
                                            <label class="lbst1"><input class="rast1" id="stop2" name="stop1" type="radio" onclick="showOrHide('show',2)"><spring:message code="order_no_require"/></label>
                                        </div>
                                    </div>
                                </div>
                                <div id="show">
                                    <c:forEach items="${subList}" var="signList" varStatus="status">
                                        <c:set var="inputFlag" scope="page" value="0"></c:set>
                                        <!-- 折行开始 -->
                                        <c:if test="${status.index%2 == 0}">
                                            <div class="data clearfix">
                                        </c:if>
                                            <!-- 右数据 -->
                                            <c:if test="${status.index%2 == 0}">
                                                 <div class="ch_middle fl">
                                            </c:if>
                                            <!-- 左数据 -->
                                            <c:if test="${status.index%2 == 1}">
                                                <div class="ch_middle fr">
                                            </c:if>
                                                    <!-- 显示之前的数据 -->
                                                    <c:forEach items="${ShowOptionList}" var="itemShow" varStatus="status2">
                                                        <c:if test="${signList.styleOption.itemValue eq itemShow.optionValue}">
                                                            <input type="hidden" name="signFlag" value="1">
                                                            <c:set var="inputFlag" scope="page" value="1"></c:set>
                                                            <div class="ckBox fl">
                                                                <input type="checkbox"  onclick="changeTitleInfo()" name="signOptionList" checked id="signOptionList${status2.index}" value="${signList.styleOption.itemCd}-${signList.styleOption.itemValue}">
                                                                <input type="hidden" value="${signCode}">
                                                            </div>
                                                            <div class="fl clearfix styleSelectBox notpointer">
                                                                <p class="rtname flTxt" style="width:260px;"><label for="SigncheckBox${status2.index}">${signList.styleOption.itemNameCn}</label></p>
                                                            </div>
                                                        </c:if>
                                                    </c:forEach>
                                                    <!-- 未显示过的数据 -->
                                                     <c:if test='${pageScope.inputFlag == "0"}'>
                                                           <div class="ckBox fl">
                                                                <input type="checkbox" onclick="changeTitleInfo()" id="signOptionList${status.index}" name="signOptionList" value="${signList.styleOption.itemCd}-${signList.styleOption.itemValue}">
                                                                <input type="hidden" value="${signCode}">
                                                            </div>
                                                            <div class="fl clearfix styleSelectBox notpointer">
                                                                <p class="rtname flTxt" style="width:260px;"><label for="signOptionList${status.index}">${signList.styleOption.itemNameCn}</label></p>
                                                            </div>
                                                     </c:if>
                                                </div>
                                        <c:if test="${status.index%2 == 1 || status.index == (fn:length(subList)-1)}">
                                             </div>
                                        </c:if>
                                    </c:forEach>
                                </div>
                                 </form>
                                
                    </div>
                    
        
                </div>
           
<!-- 订单信息显示 -->
<%@ include file="/WEB-INF/views/modules/order/orderCreateTitle.jsp"%>

        

        </div>

        <div class="Pre-box">
            <!-- 上一步 -->
            <div class="Pre-1" onclick='window.location.href="${ctx}/order/createOrder3/form6?id=0"'><spring:message code="order_back_step"/></div>
            <!-- 取消 -->
            <div class="Pre-2" onclick="window.parent.frames[0].location.href = '${ctx}/order/order/'"><spring:message code="order_cancel"/></div>
            <!-- 下一步 -->
            <div class="Pre-1" onclick="saveForm.save(0);"><spring:message code="order_next_step"/></div>
        </div>
    </div>
    <script>
    var windowH2 = window.parent.windowHIframe;
    $('.TxtInfoSm1,.scrollBox').css('height', windowH2 - 368);
    var listH = $(':root').css('height');
    $(window.parent.$("#mainFrame").css('height',listH));
</script>
</body>
</html>